import Vue from 'vue'
import App from './App'
// import store from './static/js/store/store.js';
import request from '@/common/request.js'
Vue.prototype.$request = request;
//Uview-ui
import uView from 'uview-ui';
Vue.use(uView);

// 线上上传图片路径 https://trq.wqzsgas.com 
Vue.prototype.$fileImg = 'https://trq.wqzsgas.com/api/'

//api地址
Vue.prototype.$url = 'https://trq.wqzsgas.com/addons/tianranqi/'
Vue.prototype.$api = 'https://trq.wqzsgas.com/api/'
Vue.prototype.$imgurl = 'https://trq.wqzsgas.com/'
// Vue.prototype.$testapi = 'https://tianranqi.com:8890/addons/tianranqi/api/'

Vue.prototype._header = {
	token: uni.getStorageSync('token'),
	'content-type': 'application/json'
}


// http拦截器，此为需要加入的内容，如果不是写在common目录，请自行修改引入路径
import httpInterceptor from '@/common/http.interceptor.js'
// 这里需要写在最后，是为了等Vue创建对象完成，引入"app"对象(也即页面的"this"实例)
Vue.use(httpInterceptor, app)

Vue.prototype.$navTo = function(url) {
	uni.navigateTo({
		url: url
	});
}

Vue.prototype.$showToast = (title) => {
	uni.showToast({
		icon: 'none',
		title: title
	})
}
Vue.prototype.$downFile = (url) => {
	uni.downloadFile({
		url: url,
		success: (res) => {
			console.log(res);
			if (res.statusCode == 200) {
				uni.openDocument({
					filePath: res.tempFilePath,
					success: () => {
						// _this.$showToast('打开文档成功')
					}
				})
			}
		},
		fail: (err) => {
			console.log(err);
		}
	})
}
Vue.prototype.$previewImage = (arr, index) => {
	uni.previewImage({
		count: index,
		urls: arr
	})
}

Vue.config.productionTip = false
App.mpType = 'app'

const app = new Vue({
	...App,
	// store,
	beforeCreate() {
		Vue.prototype.$bus = this // 安装全局事件总线，$bus就是当前应用的vm
	}
})
app.$mount()
